package com.yihu.cms.action;

import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;

import com.yihu.beans.products.CommodityCategory;
import com.yihu.cms.service.CommodityCategoryService;

@Controller
public class CommodityCategoryController extends BaseController {
	
	protected final Logger log = LoggerFactory.getLogger(this.getClass());
	
	private CommodityCategoryService cc = new CommodityCategoryService();
	
//	@RequestMapping(value = "/CommodityCategory", method = RequestMethod.GET)
	@RequestMapping(value = "/commodityCategory/list", method = RequestMethod.GET)
	public @ResponseBody Object getCommodityCategory() {
		log.info("getCommodityCategory.");
		List<CommodityCategory> result = cc.getCommodityCategory();
//		String resultBack = JSON.toJSONString(result);
//		log.info("result=" + resultBack);
		return getResult(0, result);
	}
	
	@RequestMapping(value = "/commodityCategory/{id}", method = RequestMethod.GET)
	public @ResponseBody Map<String, Object> getArtwork(@PathVariable("id") String pId) {
		log.info("getCommodityCategory=" + pId);
//		String artworkJson = as.getById(id);
//		return cc.getCommodityCategoryBypId(pId);
		return getResult(0, cc.getCommodityCategoryBypId(pId));
	}
	
}
